package and.process;

import java.util.List;

import and.bean.BaseBean;
import and.common.MyCommon;
import and.tools.FileHelper;

public class SaveProcess {
	public void saveBaseBeanFile(List<BaseBean> list) throws Exception {
		FileHelper.writeToSD(MyCommon.FILEPATH,MyCommon.SAVEFILENAME,
				buildStr(list));
		if (MyCommon.DEBUG) {
			String result = FileHelper.read(MyCommon.FILEPATH
					+MyCommon.SAVEFILENAME, "utf-8");
			System.out.println(result);
		}

	}

	private String buildStr(List<BaseBean> list) {
		StringBuilder sb = new StringBuilder();
		BaseBean bean ;
		for(int i=0;i<list.size();i++){
			bean = list.get(i);
			sb.append(bean.getName());
			sb.append(";");
			sb.append(bean.getQishu());
			sb.append(";");
			sb.append(bean.getDate());
			sb.append(";");
			sb.append(bean.getNum());
			sb.append("\n");
		}
		return sb.toString();
	}
}
